const getBarChart = (data: any) => {
  let { seriesData, yAxisData, colorList } = data
  const option: any = {
    grid: {
      left: 0,
      right: 60,
      top: 0, //拉伸距离顶部高度
      bottom: 0, //拉伸距离底部高度
      containLabel: true
    },
    xAxis: {
      type: 'value',
      axisLine: {
        //轴线
        show: true
      },
      splitLine: {
        //分割线
        show: false
      }
    },
    yAxis: {
      type: 'category',
      data: yAxisData?.reverse(),
      axisTick: {
        // 刻度线
        show: false
      },
      axisLine: {
        //轴线
        show: false
      }
    },
    series: [
      {
        barWidth: 16, //柱图宽度
        data: seriesData?.reverse(),
        type: 'bar',
        label: {
          //数值样式
          normal: {
            show: true,
            position: 'right', //柱形右边
            color: 'auto'
          }
        },
        itemStyle: {
          normal: {
            //这里设置柱形图圆角 [左上角，右上角，右下角，左下角]
            barBorderRadius: [20, 20, 20, 20],
            color: function (params: any) {
              return colorList[params.dataIndex % colorList.length]
            }
          }
        }
      }
    ]
  }
  if (yAxisData.length > 40) {
    option.dataZoom = [
      {
        id: 'dataZoomY',
        type: 'slider',
        yAxisIndex: [0],
        filterMode: 'empty',
        start: 100,
        end: 50,
        zoomLock: true,
        brushSelect: false
      }
    ]
  }
  return option
}
export default getBarChart
